import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import Home from '../views/Home.vue'
import home from '@/views/home/home.vue'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    redirect: 'home'
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login/login.vue')
  },
  {
    path: '/develop',
    name: 'develop',
    component: () => import('../views/developerPlatform/conditionSheet.vue'),
    meta: {
      requireAuth: true
    }
  },
  {
    path: '/home',
    name: 'home',
    component: home => import('../views/home/home.vue')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('../views/register/register.vue')
  },
  {
    path: '/personCenter',
    name: 'personCenter',
    component: () => import('../views/person/personCenter.vue')
  },
  {
    path: '/shoppingMall',
    name: 'shoppingMall',
    component: () => import('../views/shoppingMall/shoppingMall.vue')
  },
  {
    path: '/purse',
    name: 'purse',
    component: () => import('../views/person/purse.vue')
  },
  // {
  //   path: '/',
  //   name: 'Home',
  //   component: Home
  // },
  {
    path: '/challenge',
    name: 'challenge',
    component: () => import('../views/challenge/challenge.vue')
  },
  {
    path: '/basicInformation',
    name: 'basicInformation',
    component: () => import('../views/person/basicInformation.vue')
  },
  {
    path: '/set',
    name: 'set',
    component: () => import('../views/person/set.vue')
  },
  {
    path: '/message',
    name: 'message',
    component: () => import('../views/person/message.vue')
  },
  {
    path: '/transactionRecord',
    name: 'transactionRecord',
    component: () => import('../views/person/transactionRecord.vue')
  },
  {
    path: '/createChallenge',
    name: 'createChallenge',
    component: () => import('../views/challenge/createChallenge.vue'),
    meta: {
      requireAuth: true
    }
  },
  {
    path: '/challengeDetail',
    name: 'challengeDetail',
    component: () => import('../views/challenge/challengeDetail.vue'),
    meta: {
      requireAuth: true
    }
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
    path: '/goodsDetail',
    name: 'goodsDetail',
    component: () => import('../views/shoppingMall/goodsDetail.vue'),
    meta: {
      requireAuth: true
    }
  },
  {
    path: '/reportMall',
    name: 'reportMall',
    component: () => import('../views/shoppingMall/reportMall.vue'),
    meta: {
      requireAuth: true
    }
  },
  {
    path: '/auditGoods',
    name: 'auditGoods',
    component: () => import('../views/shoppingMall/auditGoods.vue'),
    meta: {
      requireAuth: true
    }
  }
]

const router = createRouter({
  history: createWebHashHistory(process.env.BASE_URL),
  routes
})

export default router
